var removeDuplicates = function(nums) {
    let i = 0;
    for(j = 1;j < nums.length;j++){
        if(nums[i] != nums[j]){
            i++;
            nums[i] = nums[j]
        }
    }
    console.log(nums) //[ 1, 2, 2 ]
    console.log(i) //1
    nums = nums.splice(0,i+1)
    console.log(nums) //[ 1, 2 ]
    return nums.length //2
};

console.log(removeDuplicates([1,1,2]))
